package cn.terminus.data.customer.userrecordinfo.impl;

import cn.terminus.common.customer.bean.userrecordinfo.dto.*;
import cn.terminus.data.customer.userrecordinfo.dao.UserRecordInfoDao;
import cn.terminus.data.customer.userrecordinfo.mapper.UserRecordInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserRecordInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:19:10
 */
@Repository
public class UserRecordInfoDaoImpl implements UserRecordInfoDao {
    @Resource
    private UserRecordInfoMapper userRecordInfoMapper;

    @Override
    public Integer add(UserRecordInfoNewDto dto) {
        return userRecordInfoMapper.add(dto);
    }

    @Override
    public Integer update(UserRecordInfoEditDto dto) {
        return userRecordInfoMapper.update(dto);
    }

    @Override
    public List<UserRecordInfoResultDto> gets(UserRecordInfoGetsDto dto) {
        return userRecordInfoMapper.gets(dto);
    }

    @Override
    public List<UserRecordInfoResultDto> query(UserRecordInfoQueryDto dto) {
        return userRecordInfoMapper.query(dto);
    }

    @Override
    public Integer delete(UserRecordInfoDeleteDto dto) {
        return userRecordInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<UserRecordInfoResultDto> page(UserRecordInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<UserRecordInfoResultDto> result = (Page<UserRecordInfoResultDto>) userRecordInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), UserRecordInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer addMulti(List<UserRecordInfoNewDto> list) {
        return userRecordInfoMapper.addMulti(list);
    }


}
